﻿<%@ Page Title="" Language="C#" MasterPageFile="~/cms/cms.master" AutoEventWireup="true" CodeFile="ListGallery.aspx.cs" Inherits="cms_ListGallery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" Runat="Server">
    <h1 class="top-heading">List Gallery</h1>
    <asp:GridView ID="GVGallery" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="SqlGetAllGallery" Width="100%" 
        AllowPaging="True" AllowSorting="True" PageSize="15" 
        onrowcommand="GVGallery_RowCommand">
        <Columns>        
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Image ID="Image1" runat="server"
                        ImageUrl='<%# Eval("Image", "~/images/Gallery/{0}") %>' Width="100" Height="100" />
                </ItemTemplate>
                 <ItemStyle Width="100px" />
            </asp:TemplateField>
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                ReadOnly="True" SortExpression="ID" >
            <HeaderStyle HorizontalAlign="Center" />
            <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="Name" HeaderText="Name"
                SortExpression="Name" />
            <asp:BoundField DataField="Description" HeaderText="Description" 
                SortExpression="Description" />
                <asp:BoundField DataField="ShortName" HeaderText="Type" 
                SortExpression="ShortName" />
            <asp:HyperLinkField DataNavigateUrlFields="ID,Name" 
                DataNavigateUrlFormatString="ListGalleryImage.aspx?Id={0}&Name={1}" Text="Image">
            <ItemStyle HorizontalAlign="Center" />
            </asp:HyperLinkField>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="Edit" CommandArgument='<%# Eval("Id") %>'></asp:LinkButton>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" OnClientClick="return confirm('Do you want to delete this ?');"
                        CommandName="Delete" Text="Delete" CommandArgument='<%# Eval("Id") %>' ></asp:LinkButton>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" />
            </asp:TemplateField>
        </Columns>
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" 
            Font-Underline="False" Wrap="True" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlGetAllGallery" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="GetAllGallery" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="Id" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:HyperLink ID="hplAddNewGallery" runat="server" 
        NavigateUrl="~/cms/AddNewGallery.aspx">Add New Gallery</asp:HyperLink>
</asp:Content>

